﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.ComponentModel;

namespace JQuery
{
    public abstract class UIExtender : JQueryExtender
    {
        [JQueryElement("appendTo", true)]
        public string AppendTo
        {
            get { return GetPropertyValue<string>("AppendTo", null); }
            set { SetPropertyValue("AppendTo", value); }
        }

        [JQueryElement("axis")]
        public AxisRestriction? AxisRestriction
        {
            get { return GetPropertyValue<AxisRestriction>("AxisRestriction", null); }
            set { SetPropertyValue("AxisRestriction", value.ToString().ToLower()); }
        }

        [JQueryElement("cancel", true)]
        public string Cancel
        {
            get { return GetPropertyValue<string>("Cancel", null); }
            set { SetPropertyValue("Cancel", value); }
        }

        [JQueryElement(null, "containment", true, "parent|document|window|false")]
        public string Containment
        {
            get { return GetPropertyValue<string>("Containment", null); }
            set
            {
                if (ContainmentCoordinates == null)
                    SetPropertyValue("Containment", value);
                else
                    throw new NotSupportedException("You may not specify the containement type if you already have set up coordinates.");
            }
        }

        [JQueryElement(null, "containment", false, @"\[ ?[0-9]+, ?[0-9]+, ?[0-9]+, ?[0-9]+ ?\]")]
        public string ContainmentCoordinates
        {
            get { return GetPropertyValue<string>("ContainmentCoordinates", null); }
            set
            {
                if (Containment == null)
                    SetPropertyValue("ContainmentCoordinates", value);
                else
                    throw new NotSupportedException("You may not specify the coordinates if you have set up another containment type than the default one.");
            }
        }

        [JQueryElement("cursor")]
        public string Cursor
        {
            get { return GetPropertyValue<string>("Cursor", null); }
            set { SetPropertyValue("Cursor", value); }
        }

        [JQueryElement(null, "cursorAt", false, @"\{ ?(top|left|right|bottom): ?-?[0-9]+(, ?(top|left|right|bottom): ?-?[0-9]+)? ?\}")]
        public string CursorAt
        {
            get { return GetPropertyValue<string>("CursorAt", null); }
            set { SetPropertyValue("CursorAt", value); }
        }

        [JQueryElement("delay")]
        public int? Delay
        {
            get { return GetPropertyValue<int>("Delay", null); }
            set { SetPropertyValue("Delay", value); }
        }

        [JQueryElement("distance")]
        public int? Distance
        {
            get { return GetPropertyValue<int>("Distance", null); }
            set { SetPropertyValue("Distance", value); }
        }

        [JQueryElement(null, "grid", false, @"^(\[[0-9]+,\ ?[0-9]+\])|false$")]
        public string Grid
        {
            get { return GetPropertyValue<string>("Grid", null); }
            set { SetPropertyValue("Grid", value); }
        }

        [JQueryElement(null, "handle", true, "false")]
        public string Handle
        {
            get { return GetPropertyValue<string>("Handle", null); }
            set { SetPropertyValue("Handle", value); }
        }

        [JQueryElement("helper")]
        public string Helper
        {
            get { return GetPropertyValue<string>("Helper", null); }
            set { SetPropertyValue("Helper", value); }
        }

        [JQueryElement(null, "iframeFix", true, "true|false")]
        public string IFrameFix
        {
            get { return GetPropertyValue<string>("IFrameFix", null); }
            set { SetPropertyValue("IFrameFix", value); }
        }

        [JQueryElement("opacity")]
        public float? Opacity
        {
            get { return GetPropertyValue<float>("Opacity", null); }
            set { SetPropertyValue("Opacity", value); }
        }

        [JQueryElement("refreshPositions")]
        public bool? RefreshPositions
        {
            get { return GetPropertyValue<bool>("RefreshPositions", null); }
            set { SetPropertyValue("RefreshPositions", value); }
        }

        [JQueryElement(null, "revert", false, SerializeAs.String, @"^true|false|valid|invalid$")]
        public string Revert
        {
            get { return GetPropertyValue<string>("Revert", null); }
            set { SetPropertyValue("Revert", value); }
        }

        [JQueryElement("revertDuration")]
        public int? RevertDuration
        {
            get { return GetPropertyValue<int>("RevertDuration", null); }
            set { SetPropertyValue("RevertDuration", value); }
        }

        [JQueryElement("scope", SerializeAs = SerializeAs.String)]
        public string Scope
        {
            get { return GetPropertyValue<string>("Scope", null); }
            set { SetPropertyValue("Scope", value); }
        }

        [JQueryElement("scroll", false)]
        public bool? Scroll
        {
            get { return GetPropertyValue<bool>("Scroll", null); }
            set { SetPropertyValue("Scroll", value); }
        }

        [JQueryElement("scrollSensitivity")]
        public int? ScrollSensitivity
        {
            get { return GetPropertyValue<int>("ScrollSensitivity", null); }
            set { SetPropertyValue("ScrollSensitivity", value); }
        }

        [JQueryElement("scrollSpeed")]
        public int? ScrollSpeed
        {
            get { return GetPropertyValue<int>("ScrollSpeed", null); }
            set { SetPropertyValue("ScrollSpeed", value); }
        }

        [JQueryElement(null, "snap", true, "|true|false")]
        public string Snap
        {
            get { return GetPropertyValue<string>("Snap", null); }
            set { SetPropertyValue("Snap", value); }
        }

        [JQueryElement(null, "snapMode", false, @"^inner|outer|both$")]
        public string SnapMode
        {
            get { return GetPropertyValue<string>("SnapMode", null); }
            set { SetPropertyValue("SnapMode", value); }
        }

        [JQueryElement("snapTolerance")]
        public int? SnapTolerance
        {
            get { return GetPropertyValue<int>("SnapTolerance", null); }
            set { SetPropertyValue("SnapTolerance", value); }
        }

        [JQueryElement(null, "stack", false, "")]
        public string Stack
        {
            get { return GetPropertyValue<string>("Stack", null); }
            set { SetPropertyValue("Stack", value); }
        }

        [JQueryElement("zIndex")]
        public int? ZIndex
        {
            get { return GetPropertyValue<int>("ZIndex", null); }
            set { SetPropertyValue("ZIndex", value); }
        }
    }
}
